package ccc.virus.user.controller;

import ccc.virus.user.entity.User;
import ccc.virus.user.service.UserService;
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIConversion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * @Author:CCC
     * @Description:
     * @Date:2018/8/22 16:32
     */
    @RequestMapping("home")
    public String home(){
        System.out.println("git upload");
        return "home";
    }

    /**
     * @Author:CCC
     * @Description:获取用户信息
     * @Date:2018/8/21 0021
     */
    @RequestMapping("/userinfo")
    @ResponseBody
    public User getUser(HttpSession session){
        User user = (User) session.getAttribute("userinfo");
        return user;
    }

    /**
     * @Author:CCC
     * @Description:登出
     * @Date:2018/8/21 0021
     */
    @RequestMapping("/logout")
    @ResponseBody
    public String logout(HttpSession session){
        session.invalidate();
        return "login";
    }

}
